package com.dog.modules.upms.service.impl;


import cn.hutool.json.JSONUtil;
import com.dog.framework.core.dto.NotifyMsgDTO;
import com.dog.framework.core.dto.RobotBasicParamReqDTO;
import com.dog.framework.core.enums.NotifyRobotMsgEnum;
import com.dog.framework.email.domain.MailSendEntity;
import com.dog.framework.email.domain.MailSendResult;
import com.dog.framework.email.service.MailService;
import com.dog.modules.upms.producer.NotifyRobotProducer;
import com.dog.modules.upms.service.SendService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;


/**
 * @date
 * @author liuxk
 */
@Slf4j
@Service
public class SendServiceImpl implements SendService {

    @Autowired
    private MailService mailService;

    @Autowired
    private NotifyRobotProducer notifyRobotProducer;


    @Async
    @Override
    public void sendMail(MailSendEntity entity) {
        MailSendResult result = mailService.sendMail(entity);
    }


    @Override
    public void sendRabbitMq(RobotBasicParamReqDTO req) {
        log.info("sending rabbit mq msg : {}", JSONUtil.toJsonStr(req));
        notifyRobotProducer.sendMsg(new NotifyMsgDTO<RobotBasicParamReqDTO>(NotifyRobotMsgEnum.BASIC_PARAM_REQ.getCmd(), req));
    }



}
